﻿// owner 蒋家伟

#include "UnitTestUtils.h"
#include <iostream>

void jsdk::UnitTestUtils::showPrecent(uint16_t precent)
{
    uint16_t real = precent % 101; // 百分比小于100
    char x[5] = {};
    sprintf_s(&x[0], 4, "%3d", real);
    x[3] = '%';
    printf("Precent : \r%s>", x);
    std::fflush(stdout);
}

void jsdk::UnitTestUtils::showAbnormalUnitTest(const std::string & filePath, const std::string & function, const uint32_t rowNumber, const std::wstring & ownerName, const std::wstring & time, const std::wstring & description)
{
    bool success = StringUtils::isHeadFile(filePath.c_str());
    success = StringUtils::isCppFile(filePath.c_str());

    std::cout << "**************Error_Start**************\n";
    std::cout << "FilePath    : " + filePath << std::endl;
    std::cout << "Function    : " + function << std::endl;
    std::cout << "RowNumber   : " + std::to_string(rowNumber) << std::endl;
    std::cout << "OwnerName   : " + StringUtils::toString(ownerName) << std::endl;
    std::cout << "Time        : " + StringUtils::toString(time) << std::endl;
    std::cout << "Description : " + StringUtils::toString(description) << std::endl;
    std::cout << "***************Error_End***************\n";

#ifdef _MSC_VER
    __debugbreak();
#endif
}

void jsdk::UnitTestUtils::showUnitTest(const std::string & filePath, const std::string & function, const uint32_t rowNumber, const std::wstring & ownerName, const std::wstring & time, const std::wstring & description)
{
    std::cout << "**************Success_Start**************\n";
    //std::cout << "FilePath    : " + filePath << std::endl;
    //std::cout << "Function    : " + function << std::endl;
    //std::cout << "RowNumber   : " + std::to_string(rowNumber) << std::endl;
    //std::cout << "OwnerName   : " + StringUtils::toString(ownerName) << std::endl;
    //std::cout << "Time        : " + StringUtils::toString(time) << std::endl;
    std::cout << "Description : " + StringUtils::toString(description) << std::endl;
    std::cout << "***************Success_End***************\n";
}

std::wstring jsdk::UnitTestUtils::combineMsg(const std::wstring & srcValue, const std::wstring & exceptResultValue, const std::wstring & prefix)
{
    return prefix + L"结果值: " + srcValue + L", 期望值: " + exceptResultValue;
}
